ref Property |
This is an XPath property of a column in an XGrid. It refers to theXPath from thebusinessObjectto thebusinessElement.
Syntax
Inline HTML |
<div cordysType="wcp.library.ui.XGrid" id=XGridID xpathRowData = " " xpathBusinessObject = " "> <div id="" ref=sXPath></div> </div> |
Possible Values
Parameter | Description |
---|---|
sXPath | String that denotes a valid XPath to thebusinessElementof abusinessObject. |
Remarks
Consider the XML response of a request for employees from the Northwind database.
<data> <GetEmployeesResponse xmlns="http://schemas.cordys.com/1.0/demo/northwind"> <tuple> <old> <Employees> <EmployeeID gender="female">1</EmployeeID> <FirstName>Nancy</FirstName> <LastName>Davolio</LastName> </Employees> </old> </tuple> <tuple> <new> <Employees> <EmployeeID gender="male">2</EmployeeID> <FirstName>Andrew</FirstName> <LastName>Fuller</LastName> </Employees> </new> </tuple> </GetEmployeesResponse> </data>
The businessObject in this example is<Employees>.
However, a default namespace (xmlns) is specified on<GetEmployeesResponse>. All child nodes below theGetEmployeesResponsenode inherit this default namespace. You can also specify different namespaces for these nodes.
To obtain a valid XPath expression, a prefix needs to be applied for the namespace. For example, let us usenwdas a prefix ofhttp://schemas.cordys.com/1.0/demo/northwind. This can be done in the Internet Explorer as follows.
[dataXMLDocument].setProperty("SelectionNamespaces", "xmlns:nwd= 'http://schemas.cordys.com/1.0/demo/northwind'");
The businessElementEmployeeIDcan be found using the XPath from the businessObject as follows:
ref = "nwd:EmployeeID"
Another example ofrefis:
//attribute of EmployeeID ref = "nwd:EmployeeID/@gender" //child of Order ref = "nwd:Order/nwd:OrderNumber"
Example
The following example shows how this property can be used to fill an XGrid with data, provided that thegenderattribute exists.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html onapplicationready="getData()"> <head> <title>ref property</title> <script src="/cordys/wcp/application.js"></script> <script> function getData() { //collects data from busdataIsland and bind to xgrid bdiEmployees.reset(); employeesGrid.bindData( bdiEmployees.data); } </script> <script type="cordys/xml" id="details"> <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Body> <GetEmployeesObjects xmlns="http://schemas.cordys.com/DemoWebServices"> <fromEmployeeID>1</fromEmployeeID> <toEmployeeID>10</toEmployeeID> </GetEmployeesObjects> </SOAP:Body> </SOAP:Envelope> </script> </head> <body scroll="no" leftmargin="0" topmargin="0"> <div cordysType="wcp.library.data.BusDataIsland" async="false" id="bdiEmployees" automatic="false" request="details.XMLDocument"> </div> <div style="width:100%;height:100%;overflow:hidden"> <div cordysType="wcp.library.ui.XGrid" id="employeesGrid" xpathRowData = ".//*[local-name()='data']/*[local-name()='GetEmployeesObjectsResponse']/*[local-name()='tuple']"; xpathBusinessObject = ".//*[local-name()='Employees']" style="width:95%;height:70%"> <div id="EmployeeID" ref=".//*[local-name()='EmployeeID']/@gender" dataType="integer">EmployeeID</div> <div id="Gender" ref=".//*[local-name()='gender']">Gender</div> <div id="LastName" ref=".//*[local-name()='LastName']">LastName</div> </div> </div> </body> </html>